package com.example.demo.domain.exam;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.example.demo.annotation.Display;
import com.example.demo.enums.LanguageType;
import com.example.demo.enums.QuestionType;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.sql.Timestamp;
import java.util.List;

@Data
@RequiredArgsConstructor
@TableName(value = "user_exam_ans")
public class UserExamAns {

    @Display("答案标识")
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @Display("用户标识")
    @TableField(value = "user_id")
    private Long userId;

    @Display("考试标识")
    @TableField(value = "exam_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long examId;

    @Display("试卷标识")
    @TableField(value = "paper_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long paperId;

    @Display("题目标识")
    @TableField(value = "question_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long questionId;

    @Display("题目类型")
    @TableField(value = "question_type")
    private QuestionType questionType;

    @Display("题目答案")
    @TableField(value = "content")
    private String content;

    @Display("创建时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(value = "create_time")
    private Timestamp createTime;

    @Display("语言选择")
    @TableField("type")
    private LanguageType type;

    @Display("答案选项")
    @TableField(exist = false)
    private List<ExamUserAnswerOption> options;

    @Display("当前答案得分")
    @TableField(exist = false)
    private ExamUserSingleQuesScore singleQuesScore;

}
